import { BaseEntity } from '../base';
import { Column, Index, Entity } from 'typeorm';

/**
 * 系统用户
 */
@Entity('base_sys_user')
export class BaseSysUserEntity extends BaseEntity {
  @Index()
  @Column({ comment: '部门ID', nullable: true })
  departmentId: number;

  @Index()
  @Column({ comment: '创建者ID', nullable: true })
  userId: number;

  @Column({ comment: '姓名', nullable: true })
  name: string;

  @Index({ unique: true })
  @Column({ comment: '用户名', length: 100 })
  username: string;

  @Column({ comment: '密码' })
  password: string;

  @Column({
    comment: '密码版本, 作用是改完密码，让原来的token失效',
    default: 1,
  })
  passwordV: number;

  @Column({ comment: '昵称', nullable: true })
  nickName: string;

  @Column({ comment: '头像', nullable: true })
  headImg: string;

  @Index()
  @Column({ comment: '手机', nullable: true, length: 20 })
  phone: string;

  @Column({ comment: '邮箱', nullable: true })
  email: string;

  @Column({ comment: '备注', nullable: true })
  remark: string;

  @Column({ comment: '状态 0-禁用 1-启用', default: 1 })
  status: number;

  // 新增：余额字段
  @Column({ type: 'numeric', precision: 16, scale: 2, default: 0, comment: '余额' })
  balance: number;

  // 新增：token数量字段
  @Column({ type: 'int', default: 0, comment: 'token数量' })
  tokens: number;  // token数量字段

  // 新增：积分数量字段
  @Column({ type: 'int', default: 0, comment: '积分数量' })
  points: number;  // 积分数量字段

  // 部门名称
  departmentName: string;

  // 角色ID列表
  roleIdList: number[];

  //站点相关字段
  @Column({ type: 'varchar', length: 64, nullable: true,comment: '分站名称' })
  siteName: string;

  @Column({ type: 'varchar', length: 255, nullable: true,comment: '域名' })
  siteDomain: string;

  @Column({ type: 'varchar', length: 255, nullable: true, comment: 'LOGO URL' })
  siteLogo: string;

  // 微信小程序相关
  @Column({ type: 'varchar', length: 64, nullable: true, comment: '小程序AppID' })
  wxAppId: string;

  @Column({ type: 'varchar', length: 128, nullable: true, comment: '小程序AppSecret' })
  wxAppSecret: string;

  @Column({ type: 'varchar', length: 64, nullable: true, comment: '小程序名称' })
  wxAppName: string;

  @Column({ type: 'varchar', length: 64, nullable: true, comment: '小程序原始ID' })
  wxAppOriginalId: string;

  @Column({ type: 'varchar', length: 255, nullable: true, comment: '小程序二维码URL' })
  wxAppQrcode: string;

  // 微信支付相关
  @Column({ type: 'varchar', length: 32, nullable: true, comment: '微信支付商户号' })
  wxMchId: string;

  @Column({ type: 'text', nullable: true, comment: '微信支付API密钥' })
  wxMchKey: string;

  @Column({ type: 'text', nullable: true, comment: '微信支付证书' })
  wxPayCertPath: string;

  @Column({ comment: 'socketId', nullable: true })
  socketId: string;
}
